Repository navigation
Refuse mistyped npm dry-run flags, answer --help, roll up on every early stop, and stop passing Google credentials to cron collectors (#63) - #64
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request carries one commit. In
scripts/collect-pypi-country-stats.js,--helpand-hprint the usage and exit 0. Annpm_config_variable whose name after that prefix, with-and_removed, starts withdryor is within an edit distance of two ofdryrunis refused with exit code 2 before a run starts, exceptnpm_config_dry_run, which selects the dry run when it istrue; any other flag given without the--is left to npm, and the run collects as normal. The early-stop helper and the error handler incollect()call the 30-day rollup without the formerdaysFetched > 0condition, so a run that stops on a cap, a refusal or an error runs the rollup whether or not it landed a day (the error handler only when the store was opened, and the rollup itself writes nothing when no day is stored); a run that endsskipped_no_credentialsopens the store read-only and does not run the rollup. The cron route's collector list and environment allowlist move tolib/cron.js, and the allowlist dropsGOOGLE_APPLICATION_CREDENTIALSandGOOGLE_APPLICATION_CREDENTIALS_JSON; thegenerate-summary.jsstep that follows the collectors is spawned as before, without anenvoption. The telemetry collector tests spawn the collector in the fixture's temporary directory, and the README and two code comments about the month-to-date figure say that, without the ledger file, a billed query that failed is not counted. The commit message carriesFixes #63, so landing it closes that issue, which lists the six follow-up items these changes correspond to.Included
Verified on this exact tree
Commit
14ec144a485b7a1ff54680b2afd7b96cfed2ce60on base8784facd9e24acc0a9d5938781293aa39f362929, with Node v24.21.0 and npm 11.19.0 (the repository's workflows pin Node 24). The build, the tests and the two commands quoted below ran with an environment reduced toPATH,HOME,TMPDIR,LANG,TERMandCI=true; the install ran withPATHandHOMEonly.npm ci --no-audit --no-fundexited 0 (added 205 packages).npm run build(next build, Next.js 16.2.7) exited 0 withCompiled successfullyand static pages(3/3).tsconfig.json, so none was run.node --test --test-concurrency=4 test/*.test.js, which is thenpm testcommand limited to four test files at a time, exited 0 over 18 test files: tests 237, pass 237, fail 0, cancelled 0, skipped 0, todo 0.git status --porcelainprinted nothing after the build and after the tests.Cases the tests added by this commit assert, all in the run above:
--help,-hand--help --dry-runeach exit 0, print the usage on stdout with an empty stderr, and leave the fixture directory's database, budget file and run-status file unchanged (the test compares them byte for byte before and after).npm_config_dryrun=true,npm_config_dry_rn=trueandnpm_config_dyrrun=trueeach exit 2, name the variable and print the usage on stderr, and leave the same three files unchanged.parseArgsreturns{ dryRun: false }for an environment that holds thenpm_config_variablesallow_scripts,cache,global_prefix,globalconfig,init_module,local_prefix,loglevel,node_gyp,noproxy,npm_version,prefix,user_agentanduserconfigtogether, and{ dryRun: true }oncenpm_config_dry_run=trueis added to it.daysFetched0,asOfequal to the stored day and that day's row inpypi_country_downloads, in five cases: a dry-run estimate over the per-query cap (refused_cap), a billed job refused at the byte ceiling (refused_cap), an estimate that would pass the monthly cap (capped_month), an unreadable dry-run estimate (error) and a failing billed call (error).collectorEnv, givenPATH,NPM_PACKAGES,GOOGLE_APPLICATION_CREDENTIALS,GOOGLE_APPLICATION_CREDENTIALS_JSON,GOOGLE_CLOUD_PROJECTandCRON_SECRET, returns onlyPATHandNPM_PACKAGES; each allowlisted name other thanPATH,NODE_ENVandHOMEappears in the source of a collector script the route runs; and the route's collector list does not containcollect-pypi-country-stats.js.REGISTRY_URLremoved from its environment and a.envin the fixture directory that points at the fixture server, makes one request to that server and exits 0.Two commands run on this tree, with their output:
After the second command
git status --porcelainprinted nothing, with and without--ignored -- data.Not included
None.
How to merge
Rebase and merge, so that each change stays its own commit on
main.